POV-Ray : Newsgroups : povray.binaries.images : joining the greeble-madness :) : Re: Question Server Time
7 Aug 2024 15:21:13 EDT (-0400)
  Re: Question  
From: Zeger Knaepen
Date: 16 May 2006 09:10:18
Message: <4469cf3a$1@news.povray.org>
"How Camp" <hac### [at] gmailcom> wrote in message 
news:4469c8f4$1@news.povray.org...
> "Zeger Knaepen" <zeg### [at] povplacecom> wrote in message 
> news:4469bfe2@news.povray.org...
> 
> > Right now I'm trying a "universal 4-sided polygon greeble-cell 
generator",
> > with 2 points at the same location.  Looks useful imho.
> 
> 
> Wow, this is really nice.  What more can you share about this 
technique?

here's some code:

-- start code --
camera {
 location <-2,5,-5>/3
 look_at <-.5,.5,0>
}
light_source {<750,180,750> rgb 1+<.5,.4,.3>}
light_source {<-150,180,-75> rgb <.3,.4,.5> }//shadowless}
light_source {<750,80,-500> rgb <.4,.5,.9>/4 shadowless}
light_source {<-75,80,500> rgb 1+<.4,.5,.9>/4}
#declare Seed=seed(4);
#macro Verlaag4(X)
 #local R=X-(1+rand(Seed)*.25);
 R
#end

#macro PointAt(H1,H2,P)
 #local R=H1+(H2-H1)*P;
 R
#end
#macro VerdeelVierhoek(H1,H2,H3,H4,Diepte,Seed)
 #local H1=H1*<1,1>;
 #local H2=H2*<1,1>;
 #local H3=H3*<1,1>;
 #local H4=H4*<1,1>;
 
 #if (Diepte<0)
  #local R=.002;
  #local R2=R*(3+rand(Seed)*0);
  #local M=(H1+H2+H3+H4)/4;
  #local NH1=H1+vnormalize(M-H1)*R2;
  #local NH2=H2+vnormalize(M-H2)*R2;
  #local NH3=H3+vnormalize(M-H3)*R2;
  #local NH4=H4+vnormalize(M-H4)*R2;
   #local NH1=<NH1.u,NH1.v>;
   #local NH2=<NH2.u,NH2.v>;
   #local NH3=<NH3.u,NH3.v>;
   #local NH4=<NH4.u,NH4.v>;
  union {
   prism {
    linear_spline
    linear_sweep
    -.0001,0,
    5
    H1,H2,H3,H4,H1
   }
   #if (vlength(NH1-NH2)!=0) cylinder 
{<NH1.u,0,NH1.v>,<NH2.u,0,NH2.v>,R} #end
   #if (vlength(NH2-NH3)!=0) cylinder 
{<NH2.u,0,NH2.v>,<NH3.u,0,NH3.v>,R} #end
   #if (vlength(NH3-NH4)!=0) cylinder 
{<NH3.u,0,NH3.v>,<NH4.u,0,NH4.v>,R} #end
   #if (vlength(NH4-NH1)!=0) cylinder 
{<NH4.u,0,NH4.v>,<NH1.u,0,NH1.v>,R} #end
   sphere {<NH1.u,0,NH1.v>,R}sphere {<NH2.u,0,NH2.v>,R}
   sphere {<NH3.u,0,NH3.v>,R}sphere {<NH4.u,0,NH4.v>,R}
   prism {
    linear_spline
    linear_sweep
    0,R,
    5
    NH1,NH2,NH3,NH4,NH1
   }
  }
 #else
  #local Procent1=.5+(rand(Seed)-rand(Seed))*.3;
  #local Procent2=.5+(rand(Seed)-rand(Seed))*.3;
  #local H12=PointAt(H1,H2,Procent1);
  #local H34=PointAt(H4,H3,Procent1);

  #local H23=PointAt(H2,H3,Procent2);
  #local H41=PointAt(H1,H4,Procent2);
  
  #local HM=PointAt(H12,H34,Procent2);
  VerdeelVierhoek(H1,H12,HM,H41,Verlaag4(Diepte),Seed)
  VerdeelVierhoek(H12,H2,H23,HM,Verlaag4(Diepte),Seed)
  VerdeelVierhoek(HM,H23,H3,H34,Verlaag4(Diepte),Seed)
  VerdeelVierhoek(H41,HM,H34,H4,Verlaag4(Diepte),Seed)
 #end
#end
#declare obj=
union {
 #declare Depth=4;
 union {
  VerdeelVierhoek(<-1,0>,<-1,1>,<1,1>,<1,0>,Depth,Seed)
  union {
   VerdeelVierhoek(<-1,0>,<1,0>,<1,-1>,<1,-1>,Depth,Seed)
   matrix <
    1,0,0,
    0,1,0,
    0,.5,1,
    0,0,0
    >
  }
  translate -x+y
  matrix <
   1,.5,0,
   0,1,0,
   0,0,1,
   0,0,0
   >
 }
 union {
  VerdeelVierhoek(<-1,0>,<-1,1>,<1,1>,<1,0>,Depth,Seed)
  union {
   VerdeelVierhoek(<-1,0>,<1,0>,<1,-1>,<1,-1>,Depth,Seed)
   matrix <
    1,0,0,
    0,1,0,
    0,.5,1,
    0,0,0
    >
  }
  scale <-1,1,1>
  translate x+y
  matrix <
   1,-.5,0,
   0,1,0,
   0,0,1,
   0,0,0
   >
 }
 pigment {rgb 1}
 finish {specular 1}
}
-- end code --

I still need to add the greebles themselves, but that shouldn't be too 
much of a problem.

cu!
-- 
#macro G(b,e)b+(e-b)*C/50#end#macro _(b,e,k,l)#local C=0;#while(C<50)
sphere{G(b,e)+3*z.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1;
#end#end _(y-x,y,x,x+y)_(y,-x-y,x+y,y)_(-x-y,-y,y,y+z)_(-y,y,y+z,x+y)
_(0x+y.5+y/2x)_(0x-y.5+y/2x)            // ZK http://www.povplace.com


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.